# -*- coding: utf-8 -*-
"""
Created on Mon Mar 28 08:00:10 2011

@author: Particulier
"""

import guidata
guidata.qapplication() # not required if a QApplication has already been created

import guidata.dataset.datatypes as dt
import guidata.dataset.dataitems as di
import os, datetime, numpy as np


from guidata.dataset.datatypes import DataSet, BeginGroup, EndGroup
from guidata.dataset.dataitems import (FloatItem, IntItem, BoolItem, ChoiceItem,
                             MultipleChoiceItem, ImageChoiceItem, FilesOpenItem,
                             StringItem, TextItem, ColorItem, FileSaveItem,
                             FileOpenItem, DirectoryItem, FloatArrayItem,
                             DateItem, DateTimeItem)
from guidata.dataset.datatypes import ActivableDataSet
from  AdwinPro import AIN_F8_14_revb3 # import class ADWinPro

def InitAcq(param,item,value):
    print param.ProjectName
    print param.FileName
    print param.srate
    print param.nbchannel
    print param.nbpoint
    print param.level


def SimpleAcq(param,item,value):
    pass

def averageAcq(param,item,value):
    pass

def InitParam(param,item,value):
    pass

class ParamInput(dt.DataSet):
    """ Input parameters"""
    g1 = BeginGroup("group 1")
    ProjectName = StringItem("Project name",default="data")
    FileName = StringItem("File name",default="temp").set_pos(col=1,colspan=2)
    srate = IntItem("Sampling rate [Hz]",default=2000000, min=2000, max=2000000, help="Sampling rate [Hz]")
    nbchannel = IntItem("Channel number",default=1, min=1, max=8, help="Channel number [1..8]").set_pos(col=1,colspan=2)
    nbpoint = IntItem("Buffer size", default=8192,min=128, max=1048575, help="Acquisition buffer size").set_pos(col=1,colspan=2)
    level = ChoiceItem("Input level",[(0,"+/- 10V"),(1,"+/- 5V"),(2,"+/- 2.5V"),(3,"+/- 1.25V")],default=0).set_pos(col=1,colspan=2)
    triggeredge = ChoiceItem("Trigger edge",["rising edge","falling edge"],default=1)
    average = IntItem("average number", default=1,min=1, max=999, help="Average number").set_pos(col=1,colspan=2)
    nbpfft = IntItem("Length FFT", default=1024,min=512, max=65536, help="Lenght FFT").set_pos(col=1,colspan=3)
    rightfrequency = IntItem("Right frequency [Hz]", default=50000,min=1000, max=1000000, help="Lenght FFT").set_pos(col=1,colspan=2)
    bootbutton=di.ButtonItem("Boot",InitAcq,None,1,"Adwin pro initialisation")
    simpleacqbutton = di.ButtonItem("Simple acq.",SimpleAcq,None,2,"Single acquisition")
    averageacqbutton = di.ButtonItem("average acq.",averageAcq,None,3,"Average acquisition")
    _g1 = EndGroup("group 1")
param=ParamInput()
param.edit()
print param.ProjectName
print param.FileName
print param.srate
print param.nbchannel
print param.nbpoint
print param.level


